<template>
    <van-nav-bar title="评价详情" left-text="" left-arrow @click-left="goBack" />
    <section class="aui-flexView">
        <!-- 订单详细 -->
        <section class="aui-scrollView">
            <!-- 订单状态 -->
            <div class="aui-pay-change">
                <div class="aui-flex">
                    <div class="aui-flex-box">
                        <h3>{{ detail.status_text }}</h3>
                    </div>
                    <div class="aui-pay-zfb">
                        <img src="/assets/images/icon-zfb.png" alt="" />
                    </div>
                </div>
            </div>

            <!-- 收货地址 -->
            <div class="aui-flex">
                <div class="aui-flex-add">
                    <img :src="LoginUser.avatar" alt="" />
                </div>
                <div class="aui-flex-box">
                    <h3>
                        {{ detail.consignee }} <em> {{ detail.mobile }}</em>
                    </h3>
                    <p>{{ detail.region_text }}</p>
                </div>
            </div>

            <!-- 订单商品 -->
            <div class="aui-commodity-bg">
                <div class="item" v-for="item in detail.info" :key="item.id">
                    <div class="aui-flex">
                        <div class="aui-commodity-img">
                            <img :src="item.product.thumb_text" />
                        </div>
                        <div class="aui-flex-box">
                            <h4 class="van-ellipsis">商品名称：{{ item.product.name }}</h4>
                            <p>商品单价：￥{{ item.price }}</p>
                            <span class="aui-barter-time">七天退换</span>
                        </div>
                        <div>
                            <h5>￥{{ item.total }}</h5>
                            <p class="aui-sml-text">X{{ item.pronum }}</p>
                        </div>
                    </div>
                    <div class="aui-flex" style="flex-direction: column;">
                        <!-- 评分 -->
                        <p>
                            <van-rate v-model="item.rate" icon="fire" void-icon="fire-o" readonly />
                        </p>
                        <!-- 评价内容 -->
                        <van-field v-model="item.comment" rows="2" :border="true" autosize label="" type="textarea" />

                        <div style="display: flex;">
                            <van-image width="8rem" height="8rem" fit="cover" 
                            v-for="(src, index) in item.proimg_list" :key="index" style="margin-right: 10px;"
                            :src="src" 
                            @click="showImagePreview(item.proimg_list)"
                            />
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </section>
</template>
<script setup>
import { showImagePreview } from 'vant';
const router = useRouter();
const route = useRoute();
const goBack = () => {
    history.back()
}
const orderid = ref(route.query.orderid ?? 0)
const detail = ref({})
const { cookies } = useCookies();
const LoginUser = reactive(cookies.get("LoginUser") ?? {});
onBeforeMount(() => {
    getInfoData()
})
const getInfoData = async () => {
    let result = await Api.orderInfo({
        busid: LoginUser.id,
        orderid: orderid.value,
    });
    if (result.code == 1) {
        detail.value = result.data
    }
}
</script>
<style>
@import url('/assets/css/info.css');
</style>